<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" MasterPageFile="~/GUIMaster.Master"
    AutoEventWireup="true" CodeBehind="messages.aspx.cs" Inherits="TripLOA.GUI.messages"
    Title="Private Messages" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Messages/messages.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="../stats/stats.css" type="text/css" />
    <link href="../Messages/jquery.autocomplete.css" rel="stylesheet" type="text/css" />

    <script src="../Messages/SelectAllCheckboxes.js" type="text/javascript"></script>
    <script src="../Messages/jquery.autocomplete.js" type="text/javascript"></script>
    <script src="../Messages/smileys.js" type="text/javascript"></script>
    <script src="../Messages/InitPage.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentHomePage" runat="server">
    <div>
        <!-- Title -->
        <h1>
            <asp:Label ID="Label_TitleMess" meta:resourcekey="TitleMess" runat="server"></asp:Label>
        </h1>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server">
            <ProgressTemplate>
                <asp:Image CssClass="ProgressTemplate" ID="Image2" runat="server" ImageUrl="../master/resourcesNew/img/loader.gif" />
            </ProgressTemplate>
        </asp:UpdateProgress>
           <!-- Panel to send messages -->
            <div id="statsMainContainer" style="width:552px;margin:0;height:292px;margin-bottom:20px;display:none" >
          <div id="topLeftCorner"></div>
        <div id="topRightCorner"></div>
        <div id="bottomLeftCorner"></div>
        <div id="bottomRightCorner" style="z-index:1;elevation:lower"></div>
        <div id="topBorder" style="width:525px;"></div>
        <div id="bottomBorder" style="width:525px;"></div>
        <div id="leftBorder" style="height:262px"></div>
        <div id="rightBorder"  style="height:262px"></div>
      
                <asp:Panel CssClass="PanelSendPM " ScrollBars="Auto" 
                    ID="PanelSendPM" runat="server" meta:resourcekey="PanelViewPMResource1" Width="550px">
                    <div  id="DivSendPM" style="width:550px;" >                     
                     <table >
                     <tr><td style="width:80px">                                   
                         <asp:Label ID="LabelDest" runat="server" CssClass="label_title_sec" 
                             meta:resourcekey="LabelDestResource1" Text="to : " Width="80"></asp:Label>
                     </td><td>    
                    <br />     
                        <div style="width: 150px;float:left">  
                          <asp:TextBox ID="TextBoxInsertDest" runat="server" 
                              meta:resourcekey="TextBoxInsertDestResource1" />
                          <div  style="float: left; width: 150px">
                             <div id="autoc" class="resultAutocompleteFriends">
                             
                              </div>
                              <asp:RequiredFieldValidator ID="RequiredFieldValidatorNick" runat="server" 
                                  ControlToValidate="TextBoxInsertDest" ErrorMessage="*" 
                                  meta:resourcekey="RequiredFieldValidator1Resource1" 
                                  ValidationGroup="NickSendPM"></asp:RequiredFieldValidator>
                           
                          </div>
                          </div>     
                          <div style="float:right">
                              <asp:Label ID="LabelOtherNick" runat="server"  CssClass="label_title_sec"  
                                  meta:resourcekey="LabelOtherNick" Text="altri : " Width="70"></asp:Label>
                              <asp:TextBox ID="TextBoxOtherNick" runat="server" Width="220px" />
                              <div style="text-align: right">
                                  <asp:Label ID="LabelHelpOtherNick" runat="server" Font-Size="10px" 
                                     CssClass="label_title_sec"  meta:resourcekey="LabelHelpOtherNick" Text=""></asp:Label>
                              </div>
                          </div></td></tr>
                      <tr><td>
                      <asp:Label ID="Label1" runat="server"  CssClass="label_title_sec"  
                             meta:resourcekey="Label1Resource1" Text="Oggetto : " Width="80"></asp:Label>        
                     </td>
                      <td>
                        <asp:TextBox ID="TextBox_Subject" runat="server" 
                              meta:resourcekey="TextBox_SubjectResource1" Width="450px" />                     
                     </td></tr>
                      <tr>
                      <td>
                         <asp:Label ID="LabelTextMess" runat="server"  CssClass="label_title_sec" 
                             meta:resourcekey="LabelTextMessResource1" Text="Text : " Width="80"></asp:Label>                     
                     </td>
                      <td>  
                      <div style="float:right">
                           <a class="ViewSmileys" style="font-weight:800;cursor:pointer;">Smileys</a>
                                             
                        </div>
                          <div id="SmileysContent">
         
                               </div>  
                          <asp:TextBox ID="TextBoxTextMess" runat="server" Height="91px" 
                              meta:resourcekey="TextBoxTextMessResource1" TextMode="MultiLine" Width="450px"></asp:TextBox>                     
                     </td></tr>                   
                     <tr>
                     <th></th>
                     <th>
                
                                
                            <!-- Option message -->
                        <div style="float:right">
                            <asp:Button CssClass="button_generics" ID="ButtonSend" runat="server" Height="26px"
                                OnClick="ButtonSend_Click" Text="Send" meta:resourcekey="ButtonSendResource1"
                                ValidationGroup="NickSendPM" />
                            <asp:CheckBox ID="CheckBoxPriority" Text="Priority"  CssClass="label_title_sec"  runat="server"
                                meta:resourcekey="CheckBoxPriorityResource1" />
                        </div>
                     </th></tr>
                     </table>
                      
                 
                    </div>
                </asp:Panel>
     
        
        </div>
     

              <!-- Menu -->
        <div style="height: 49px; width: 770px">
            <asp:Button ID="Btn_NewMessages" CssClass="button_generics" runat="server" meta:resourcekey="Btn_NewMessagesResource1"
                OnClick="Btn_NewMessages_Click" />
        <input id="Button1" class="button_generics" type="button" value=" <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:ltrSend%>" />"></input>
            <asp:DropDownList CssClass="button_generics" ID="DropDownListMailMode" runat="server"
                OnSelectedIndexChanged="MailMode_SelectedIndexChanged" AutoPostBack="true">
                <asp:ListItem meta:resourcekey="ListItemResource1" Selected="True">Posta in arrivo</asp:ListItem>
                <asp:ListItem meta:resourcekey="ListItemResource2">Posta in uscita</asp:ListItem>
            </asp:DropDownList>
            <asp:Button ID="ButtonDelete" runat="server" OnClick="Delete_Click" CssClass="button_generics"
                Text="Elimina" meta:resourcekey="ButtonDeleteResource1" />
            <asp:Button ID="Btn_DeleteAll" runat="server" CssClass="button_generics" OnClick="DeleteAll_Click"
                meta:resourcekey="Btn_DeleteAllResource1" />
        </div>
        <!-- Panel to see the text the messages -->
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">      
            <ContentTemplate>
                <cc1:DragPanelExtender ID="DragPanelExtender1"   DragHandleID="forDrag" TargetControlID="forDrag" runat="server">
                </cc1:DragPanelExtender>
                 <asp:Panel ID="forDrag" runat="server">
                <div id="DivMessages" runat="server" class="DivViewPM">
                    <div id="li_header">
                    </div>
                    <div id="li" style="padding-left: 0px">
                        <div class="HeadDivViewPM">
                            <!-- View Header message -->
                            <asp:UpdateProgress ID="UpdateProgress2" runat="server">
                                <ProgressTemplate>
                                    <span style="float: left; margin-left: 20px">
                                        <asp:Image ID="Image1" runat="server" ImageUrl="../master/resourcesNew/img/loader.gif" /></span>
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                            <div id="DivViewPM" runat="server" class="BodyDivViewPM">
                                <table style="margin: auto;">
                                    <tr>
                                        <th style="text-align: right">
                                            <asp:Label   ID="Label_NickTitle" CssClass="label_title_sec" runat="server" Text=""></asp:Label>
                                        </th>
                                        <th>
                                            <asp:Label ID="Label_Nick" CssClass="label_title_sec" Font-Bold="false" runat="server" Text="TripLoa"></asp:Label>
                                        </th>
                                    </tr>
                                    <tr>
                                        <th>
                                            <asp:Label ID="Label_SubjTitle" CssClass="label_title_sec" runat="server" Text=""></asp:Label>
                                        </th>
                                        <th>
                                            <asp:Label ID="Label_Subj" CssClass="label_title_sec" Font-Bold="false" runat="server" Text="autostop on-line"></asp:Label>
                                        </th>
                                    </tr>
                                </table>
                                <div style="margin-bottom:30px">
                                <div style="float: left; margin-left: 10px;">
                                <asp:Button CssClass="button_generics"  ID="LinkButtonReply" runat="server" 
                                        Text="Rispondi" meta:resourcekey="ButtonReplyResource" OnClick="LinkButtonReply_Click" />
  
                                </div>
                                <div style="float: left; margin-left: 10px">
                                    <asp:Button CssClass="button_generics" ID="LinkButtonSendReply" runat="server"
                                        Text="Invia" meta:resourcekey="ButtonSendResource1" OnClick="LinkButtonSendReply_Click" />
                                </div>
                                   </div>
                                <!-- View body message -->
                                <div style="margin-top:35px;margin: auto; text-align:center">
                                    <asp:TextBox  CssClass="txtBox_generics" Font-Size="Small" TextMode="MultiLine" ID="TextBoxViewTextPM" ReadOnly="true" runat="server"
                                        Width="360" Height="200"></asp:TextBox>
                                   
                                        <div id="DivViewTextPM"  runat="server" class="txtBox_generics" style="overflow:scroll;margin-top:35px;margin:auto;width:360px;height:200px;background-color:White;font-size:small;text-align:left;"> </div>
                              
                                </div>
                                <!-- LinkButton to close div message -->
                                <div style="margin: auto; text-align: center">
                                <input id="BtnClose" onclick="closeDivPM()" class="button_generics" type="button" value=" <asp:Literal ID="Literal3" runat="server"  meta:resourcekey="ButtonCloseResource1"  />"></input>
                                    
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="li_footer">
                    </div>
                </div>
                  
                    <input type="hidden" id="textMessPreSmile" value="" runat="server"/>
                         </asp:Panel>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="GridViewMessages" EventName="RowCommand" />
                <asp:PostBackTrigger ControlID="LinkButtonSendReply" />
            </Triggers>
    
        </asp:UpdatePanel>
            
  
        <!-- GridView to see a list of messages received or sented-->
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div>
                    <asp:GridView ID="GridViewMessages" runat="server" Width="555px" BackColor="White"
                        BorderColor="#187418" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
                        AutoGenerateColumns="False" GridLines="Horizontal" meta:resourcekey="GridViewMessagesResource1"
                        OnRowCommand="GridViewMessages_RowCommand" OnRowCreated="GridViewMessages_RowCreated"
                        PageSize="20" AllowPaging="True" OnPageIndexChanging="GridViewMessages_PageIndexChanging">
                        <FooterStyle BackColor="White" ForeColor="#187418" />
                        <RowStyle ForeColor="#187418" BackColor="White" />
                        <Columns>
                        <%-- Fields GridView --%>  
                            
                        <%-- Nick field --%>
                            <asp:HyperLinkField ControlStyle-CssClass="NickField" DataTextField="FirtReceiver"
                                DataNavigateUrlFields="FirtReceiver" DataNavigateUrlFormatString="../secure/UserProfile.aspx?Nick={0}"
                                meta:resourcekey="BoundFieldReceiver" ItemStyle-BorderColor="#187418" ItemStyle-BorderWidth="1px">
                                <ControlStyle CssClass="NickField"></ControlStyle>
                            </asp:HyperLinkField>
                            <asp:HyperLinkField ControlStyle-CssClass="NickField" DataTextField="Sender" DataNavigateUrlFields="Sender"
                                DataNavigateUrlFormatString="../secure/UserProfile.aspx?Nick={0}" meta:resourcekey="BoundFieldResource1"
                                ItemStyle-BorderColor="#187418" ItemStyle-BorderWidth="1px">
                                <ControlStyle CssClass="NickField"></ControlStyle>
                            </asp:HyperLinkField>
                                 <%-- Subject field --%>
                            <asp:TemplateField ItemStyle-BorderColor="#187418" ItemStyle-BorderWidth="1px" meta:resourcekey="BoundFieldResource2">
                                <ItemTemplate>
                         
                                    <asp:LinkButton ID="LinkButton1" OnClientClick="openDivPM()" CommandName="GoToProperties" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                                        runat="server" Text='<%# Eval("Title") %>' meta:resourcekey="LinkButton1Resource1" />
                                   <%-- Effect open div view message--%>
                                    <cc1:AnimationExtender ID="OpenAnimation" runat="server" TargetControlID="LinkButton1">
                                        <Animations>
                                           <OnClick>
                                              <Sequence>
                                                       <%-- Disable the button --%>
                                                        <EnableAction Enabled="false" />                                                   
                                                      <%-- Fade in the div --%> 
                                                        <FadeIn AnimationTarget="DivViewPM" Duration=".5" MaximumOpacity=".2"/>                 
                                                        <Parallel AnimationTarget="DivViewPM" Duration=".5">
                                                        <Color PropertyKey="color"
                                                            StartValue="#DEF17E" EndValue="#187418" />                                                 

                                                        <StyleAction Attribute="display" Value="block"/>
                                                </Parallel>                                           
                                            </Sequence>
                                          </OnClick>
                                        </Animations>
                                    </cc1:AnimationExtender>
                                </ItemTemplate>
                            </asp:TemplateField>                            
                                     <%-- Date field --%>
                            <asp:BoundField DataField="Date" ItemStyle-BorderColor="#187418" ItemStyle-BorderWidth="1px"
                                meta:resourcekey="BoundFieldResource3">
                                <ItemStyle BorderColor="#187418" BorderWidth="1px"></ItemStyle>
                            </asp:BoundField>
                              <%-- Status field --%>
                            <asp:TemplateField ItemStyle-BorderColor="#187418" ItemStyle-BorderWidth="1px" meta:resourcekey="TemplateFieldResource1">
                                <ItemTemplate>
                                    <asp:Image ID="Image_NewMess" Visible="false" runat="server" meta:resourcekey="Image_NewMessResource1" />
                                    <asp:Image ID="Image_Priority" Visible="false" runat="server" meta:resourcekey="Image_PriorityResource1" />
                                </ItemTemplate>
                                <ItemStyle BorderColor="#187418" BorderWidth="1px"></ItemStyle>
                            </asp:TemplateField>
                               <%-- checkbox field --%>
                            <asp:TemplateField ItemStyle-BorderColor="#187418" ItemStyle-BorderWidth="1px">
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelect" runat="server" />
                                </ItemTemplate>
                                   <%-- checkbox field for select all checkbox --%>
                                <HeaderTemplate>
                                    <asp:CheckBox onclick="javascript:SelectAllCheckboxes(this);" ID="chkAll" runat="server">
                                    </asp:CheckBox>
                                </HeaderTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle BackColor="#187418" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#187418" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#187418" Font-Bold="True" ForeColor="White" />
                    </asp:GridView>
                      <%-- control to set paging gridView --%>
                    <asp:DropDownList CssClass="button_generics" ID="DropDownListPageSize" runat="server"
                        AutoPostBack="true" OnSelectedIndexChanged="DropDownListPageSize_SelectedIndexChanged">
                        <asp:ListItem>5</asp:ListItem>
                        <asp:ListItem>10</asp:ListItem>
                        <asp:ListItem Selected="True">20</asp:ListItem>
                        <asp:ListItem>30</asp:ListItem>
                        <asp:ListItem>50</asp:ListItem>
                    </asp:DropDownList>
                    <asp:Label ID="LabelPageSize" runat="server" meta:resourcekey="LabelPageSize"></asp:Label>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="GridViewMessages" EventName="RowCreated" />
                <asp:PostBackTrigger ControlID="Btn_DeleteAll" />
                    <asp:PostBackTrigger ControlID="DropDownListPageSize" />
            </Triggers>
        </asp:UpdatePanel>
        
    </div>
</asp:Content>
